﻿@{
    Layout = "_AuthorLayout";
    ViewData["Title"] = "申请出书";
    var file = Model;

}
<link href="/author/css/lib/toastr/toastr.min.css" rel="stylesheet">
<div class="alert alert-success text-center">
    全部上传完成就意味着申请成功！，请注意你的姓名和ID是否正确！
</div>
<div class="alert alert-success text-center">
    上传完成刷新页面即可查看审核状态！
</div>
<div class="row">
    <div class="col-lg-12 responsive-md-100">
        <div class="card card-outline-info">
            <div class="card-header">
                <h4 class="m-b-0 text-white">提交出书申请</h4>
            </div>
            <div class="card-body">
                <form class="form-horizontal layui-form" method="post">
                    <div class="form-body">
                        <hr>

                        <div class="row p-t-20">
                            <div class="col-md-6">
                                <div class="form-group">
                                    <label class="control-label">姓名</label>
                                    <input type="text" name="name" lay-verify="required" lay-reqtext="用户名是必填项，岂能为空？" autocomplete="off" class="form-control" value="@ViewData["Name"]">
                                </div>
                            </div>
                            <div class="col-md-6">
                                <div class="form-group has-danger">
                                    <label class="control-label">ID</label>
                                    <input type="text" name="ID" class="form-control" value="@ViewData["Id"]" readonly="readonly">
                                </div>
                            </div>
                        </div>
                    </div>
                    <fieldset class="layui-elem-field">
                        <legend>上传文件</legend>
                        <div class="layui-field-box">
                            <div class="layui-upload">
                                <button type="button" class="layui-btn layui-btn-normal" id="testList">选择文稿</button>
                                <button type="button" class="layui-btn" id="testListAction">开始上传</button>
                                <div class="layui-upload-list">
                                    <table class="layui-table">
                                        <thead>
                                            <tr>
                                                <th>文件名</th>
                                                <th>大小</th>
                                                <th>状态</th>
                                                <th>操作</th>
                                            </tr>
                                        </thead>
                                        <tbody id="demoList"></tbody>
                                    </table>
                                </div>

                            </div>
                        </div>
                    </fieldset>
                    <input name="__RequestVerificationToken" type="hidden" value="CfDJ8IudBRodKY5HtMA0DFQGdtf2d09OevfpPgwhNFgeNweaoc9w8cNObbQyUqIhw7A4Ec5BL1yPYhiowB5rXXrJRYzrj77IOzeTI9Bbt44rVdDOhkFIudiG6mxRTgubBHYNFciOc_BdBqdkMAaNTx8bW1k">
                </form>
                <div class="row">
                    <div class="col-lg-12">
                        <div class="card">
                            <div class="card-title">
                                <h4>当前申请状态</h4>
                            </div>
                            <div class="card-body">
                                <div class="table-responsive">
                                    <table class="table table-hover ">
                                        <thead>
                                            <tr>
                                                <th>编号</th>
                                                <th>文件名</th>
                                                <th>当前状态</th>
                                                <th>提交时间</th>
                                                <th>通过时间</th>
                                                <th>审核人</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                            <tr>
                                                @if (file == null)
                                                {

                                                }
                                                else
                                                {
                                                    for (int i = 0; i < file.Count; i++)
                                                    {
                                                    <tr>
                                                        <th scope="row">@(i + 1)</th>
                                                        <td>@file[i].FileName</td>
                                                        @if (file[i].Statu == "正在审核")
                                                        {
                                                            <td><span class="badge badge-danger">@file[i].Statu</span></td>
                                                        }
                                                        @if (file[i].Statu == "一审通过")
                                                        {
                                                            <td><span class="badge badge-primary">@file[i].Statu</span></td>
                                                        }
                                                        @if (file[i].Statu == "二审通过")
                                                        {
                                                            <td><span class="badge badge-light">@file[i].Statu</span></td>
                                                        }
                                                        @if (file[i].Statu == "销售中")
                                                        {
                                                            <td><span class="badge badge-success">@file[i].Statu</span></td>
                                                        }

                                                        <td>@file[i].SubmitTime</td>
                                                        @if (file[i].SubmitTime == file[i].AccessTime)
                                                        {
                                                            <td>仍在审核</td>
                                                        }
                                                        @if (file[i].SubmitTime != file[i].AccessTime)
                                                        {
                                                            <td>@file[i].AccessTime</td>
                                                        }
                                                        <td>@file[i].AccessName</td>
                                                    </tr>
                                                }
                                            }
                                        </table>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    @section Scripts{
        <script src="~/author/layui/layui.js" charset="utf-8"></script>
        <script src="~/author/js/lib/toastr/toastr.min.js"></script>
        <script src="~/author/js/lib/toastr/toastr.init.js"></script>
        <script src="~/author/js/lib/sticky-kit-master/dist/sticky-kit.min.js"></script>
        <!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
        <script>
            layui.use('upload', function () {
                var $ = layui.jquery
                    , upload = layui.upload;
                //多文件列表示例
                var demoListView = $('#demoList')
                    , uploadListIns = upload.render({
                        elem: '#testList'
                        , url: '/api/upload'
                        , accept: 'file'
                        , multiple: true
                        , auto: false
                        , bindAction: '#testListAction'
                        , choose: function (obj) {
                            var files = this.files = obj.pushFile(); //将每次选择的文件追加到文件队列
                            //读取本地文件
                            obj.preview(function (index, file, result) {
                                var tr = $(['<tr id="upload-' + index + '">'
                                    , '<td>' + file.name + '</td>'
                                    , '<td>' + (file.size / 1014).toFixed(1) + 'kb</td>'
                                    , '<td>等待上传</td>'
                                    , '<td>'
                                    , '<button class="layui-btn layui-btn-xs demo-reload layui-hide">重传</button>'
                                    , '<button class="layui-btn layui-btn-xs layui-btn-danger demo-delete">删除</button>'
                                    , '</td>'
                                    , '</tr>'].join(''));

                                //单个重传
                                tr.find('.demo-reload').on('click', function () {
                                    obj.upload(index, file);
                                });

                                //删除
                                tr.find('.demo-delete').on('click', function () {
                                    delete files[index]; //删除对应的文件
                                    tr.remove();
                                    layer.msg('删除成功');
                                    uploadListIns.config.elem.next()[0].value = ''; //清空 input file 值，以免删除后出现同名文件不可选
                                });

                                demoListView.append(tr);
                            });
                        }
                        , done: function (res, index, upload) {
                            if (res.code == 0) { //上传成功
                                layer.alert('所有文件上传完毕！', { icon: 6 });
                                var tr = demoListView.find('tr#upload-' + index)
                                    , tds = tr.children();
                                tds.eq(2).html('<span style="color: #5FB878;">上传成功</span>');
                                tds.eq(3).html(''); //清空操作
                                return delete this.files[index]; //删除文件队列已经上传成功的文件
                            }
                            this.error(index, upload);
                        }
                        , error: function (index, upload) {
                            var tr = demoListView.find('tr#upload-' + index)
                                , tds = tr.children();
                            tds.eq(2).html('<span style="color: #FF5722;">上传失败</span>');
                            tds.eq(3).find('.demo-reload').removeClass('layui-hide'); //显示重传
                        }
                    });
            });

        </script>
    }

